package IMIC.NGUYENCONGHUY.SWINGDEMO;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import java.awt.FlowLayout;
import javax.swing.UIManager;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class Demo extends JFrame {

	private JPanel ABC;
	private JTextField txtDN;
	private JPasswordField TxtPW;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Demo frame = new Demo();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public Demo() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 210);
		ABC = new JPanel();
		ABC.setToolTipText("");
		setContentPane(ABC);
		ABC.setLayout(null);
		
		JLabel lblTiKhon = new JLabel("Tài Khoản");
		lblTiKhon.setBounds(35, 41, 74, 14);
		ABC.add(lblTiKhon);
		
		JLabel lblMtKhu = new JLabel("Mật Khẩu");
		lblMtKhu.setBounds(35, 80, 74, 14);
		ABC.add(lblMtKhu);
		
		txtDN = new JTextField();
		txtDN.setBounds(119, 38, 210, 20);
		ABC.add(txtDN);
		txtDN.setColumns(10);
		
		TxtPW = new JPasswordField();
		TxtPW.setBounds(119, 77, 210, 20);
		ABC.add(TxtPW);
		
		JButton btnBttDn = new JButton("Đăng Nhập");
		btnBttDn.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				if(txtDN.getText().isEmpty()){
					JOptionPane.showMessageDialog(getParent(), "Mời bạn nhập vào tên truy cập");				
				}
				else if(TxtPW.getText().isEmpty()){
					JOptionPane.showMessageDialog(getParent(), "Mời bạn nhập vào mật khẩu");
				}
			}
		});
		btnBttDn.setBounds(106, 122, 89, 23);
		ABC.add(btnBttDn);
		
		JButton btnBttT = new JButton("Thoát");
		btnBttT.setBounds(240, 122, 89, 23);
		ABC.add(btnBttT);
	}
}
